package com.hd.trans.framework.tools;


/**
 * 
 * @ClassName: HuDunEvent
 * @Description: App内传递事件
 * @author yangHuang
 * @date 2016-3-10
 * @param <T>
 */
public class HuDunEvent<T> {

    public static final int UNKNOWN = -1;//未知类型

    /**
     * reserved data
     */
    private T data;
    
    /**
     * from where
     */
    private Class<?> fromCls;

    /**
     * this code distinguish between different events
     */
    private int eventCode = UNKNOWN;
    
    
    public HuDunEvent(int eventCode) {
        this(eventCode, null, null);
    }
    
    
    public HuDunEvent(int eventCode, Class<?> fromCls) {
        this(eventCode, null,fromCls);
    }

    public HuDunEvent(int eventCode, T data, Class<?> fromCls) {
        this.eventCode = eventCode;
        this.data = data;
        this.fromCls = fromCls;
    }

    /**
     * get event code
     */
    public int getEventCode() {
        return this.eventCode;
    }

    /**
     * get event reserved data
     */
    public T getData() {
        return this.data;
    }

    public void setFromCls(Class<?> fromCls) {
        this.fromCls = fromCls;
    }

    /**
     * get where event post 
     */
	public Class<?> getFromCls() {
		return fromCls;
	}


	@Override
	public String toString() {
		return "HuDunEvent [ fromCls=" + fromCls
				+ ", eventCode=" + eventCode + "]";
	}


}
